package com.example.driftwindow;


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;

public class DengluyiActivity extends BaseActivity{
	public static String inputString = "";

	EditText EditContent;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.dengluyi_activity);
	
		super.addButtons();
		EditContent = (EditText) findViewById(R.id.editcontent);
	
		View.OnClickListener dengluhandler = new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			
				String strEditContent = EditContent.getText().toString();

				
				Uri uri = Uri.parse("");

				
				int bytesLength = strEditContent.getBytes().length;
				int sLength = strEditContent.length();
				int hasNum = bytesLength - sLength;
				if (hasNum == 0) {
					
					uri = Uri
							.parse("http://www.dengluyi.com/index2.php?type=url&client=mobile&fwmc="
									+ strEditContent);
				} else {
					
					uri = Uri
							.parse("http://www.dengluyi.com/index2.php?type=web&client=mobile&fwmc="
									+ strEditContent);
				}
				DengluyiActivity.inputString = strEditContent;
				Intent it = new Intent(Intent.ACTION_VIEW, uri);
				startActivity(it);
			}
		};
		

		ImageButton imagebutton = (ImageButton) findViewById(R.id.denglu);
		imagebutton.setOnClickListener(dengluhandler);
	}
	
	@Override
	public void onResume(){
		
		super.onResume();
		
			EditText EditContent = (EditText) findViewById(R.id.editcontent);
			EditContent.setText(DengluyiActivity.inputString);
		
	}
	
	@Override	
	protected void onPause() {
		super.onPause();

		EditText EditContent = (EditText) findViewById(R.id.editcontent);
		DengluyiActivity.inputString = EditContent.getText().toString();
	}
}
